import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ObjCreate } from "../../common/ObjCreate";
import { RobCityStepOneRankItemData } from "./RobCityStepOneRankItemData";
import { RobCityUtill } from "../RobCityUtill";
import { Language } from "../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class RobCityStepOneRankRenderer
    
    export  class RobCityStepOneRankRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            LoaderHelp.addResCallBack(ResFileConst.robCity, this.onResLoaded);
            this._bg = new Object /* flash.display.Bitmap */();
            this.addChild(this._bg);
            this._nameLabel = ObjCreate.createGTextField("", 5, 5, 150, 20, this);
            this._serverLabel = ObjCreate.createGTextField("", 5, 25, 150, 20, this);
            this._timeLabel = ObjCreate.createGTextField("", 5, 45, 150, 20, this);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc2=false;
            var loc3=null;
            var loc4=null;
            super.data = arg1;
            var loc1=arg1 as RobCityStepOneRankItemData;
            if (loc1) 
            {
                if (loc1.info) 
                {
                    loc2 = RobCityUtill.checkHasUnion(loc1.info.guildUnion);
                    this._myGuild = RobCityUtill.isMyGuild(loc1.info.proxyId, loc1.info.severId, loc1.info.guildId);
                    loc3 = "";
                    if (loc2) 
                    {
                        loc3 = Language.getString(60882);
                    }
                    this._nameLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(60931, loc1.rank, loc1.info.guildName + loc3), GlobalStyle.color9);
                    this._serverLabel.htmlText = Language.getStringByParam(60932, HTMLUtil.addColor(EntityUtil.getProxyNameByProxyAndServer(loc1.info.proxyId, loc1.info.severId), GlobalStyle.color2));
                    this._timeLabel.htmlText = Language.getStringByParam(60933, HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(loc1.info.score / 1000, false, true), GlobalStyle.color9));
                    loc4 = (loc4 = "") + (HTMLUtil.addColor(Language.getStringByParam(60931, loc1.rank, loc1.info.guildName), GlobalStyle.color4) + "\n");
                    if (loc2) 
                    {
                        if (loc1.info.guildUnion.secondGuildId > 0) 
                        {
                            loc4 = loc4 + (HTMLUtil.addColor(Language.getStringByParam(60988, loc1.info.guildUnion.secondGuildName), GlobalStyle.color4) + "\n");
                        }
                        if (loc1.info.guildUnion.thirdGuildId > 0) 
                        {
                            loc4 = loc4 + (HTMLUtil.addColor(Language.getStringByParam(60988, loc1.info.guildUnion.thirdGuildName), GlobalStyle.color4) + "\n");
                        }
                    }
                    loc4 = (loc4 = loc4 + (HTMLUtil.addColor(Language.getStringByParam(60932, EntityUtil.getProxyNameByProxyAndServer(loc1.info.proxyId, loc1.info.severId)), GlobalStyle.color1) + "\n")) + HTMLUtil.addColor(Language.getStringByParam(60933, RemainTimeTool.getRemainTimeBySeconds(loc1.info.score / 1000, false, true)), GlobalStyle.color9);
                    this.toolTipData = loc4;
                }
                else 
                {
                    this._myGuild = false;
                    this._nameLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(60931, loc1.rank, " -- -- "), GlobalStyle.color9);
                    this._serverLabel.htmlText = Language.getStringByParam(60932, HTMLUtil.addColor(" -- -- ", GlobalStyle.color2));
                    this._timeLabel.htmlText = Language.getStringByParam(60933, HTMLUtil.addColor(" -- -- ", GlobalStyle.color9));
                    this.toolTipData = null;
                }
                if (this._loaded) 
                {
                    this.onResLoaded();
                }
            }
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._loaded = true;
            if (!this._bg) 
            {
                return;
            }
            if (this._myGuild) 
            {
                this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.RobCityItemBgBigOver);
            }
            else 
            {
                this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.RobCityItemBgBigUp);
            }
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameLabel: GTextFiled;

        /* internal */ /* var */_serverLabel: GTextFiled;

        /* internal */ /* var */_timeLabel: GTextFiled;

        /* internal */ /* var */_myGuild: Boolean;

        /* internal */ /* var */_loaded: Boolean=false;
    }
